package net.lgpage.http;

import java.util.List;

public abstract class ExceptionAsynTaskHelper<Result> {
	
	int pagestart = 1;
	int pageno = 1;
	public ExceptionAsynTaskHelper(int pagestart) {
		super();
		this.pagestart = pagestart;
		this.pageno  = pagestart;
	}

	public ExceptionAsynTaskHelper() {
		super();
	}
	public abstract ExceptionAsyncTask<Result> buildTask();
	
	int isAdd = 0;
	public int getPageNo(){
		return pageno+isAdd;
	}
	public  void toAdd(){
		isAdd = 1;
		buildTask().execute();
	}
	public  void toRefesh(){
		pageno = pagestart;
		isAdd = 0;
		buildTask().execute();
	}
	public boolean isAdd(List result){
		boolean bl = isAdd == 1;
		if(result!=null&&result.size()>0&&bl){
			pageno++;
		}
		return bl;
	}

	/*public void onExecuted(List result,List list,RecyclerView.Adapter adp){
		if(isAdd(result)){
			if(list == null)list = new ArrayList<Orders>();
			int positionStart = list.size();
			int itemCount = result.size();
			list.addAll(result);
			adp.notifyItemRangeChanged(positionStart, itemCount);
		}else{
			list = result;
			adp.notifyDataSetChanged();
		}
	}*/
	
}
